package com.len.controller;



import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradeWapPayModel;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePayRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradePayResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;

import static cn.hutool.core.util.StrUtil.uuid;


@RestController
public class WapPayController {
//    public  static  String APP_ID ="2021002111647176" ;
//    public  static  String CHARSET ="UTF-8" ;
//    public  static  String APP_PRIVATE_KEY ="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCHDW1B5+04AGZjlVMTIkYeVihXbRXLsB5ZVI2jqyJ0tvi2+2bxr7xZR8yn+ancETx885aZue3ALWdpS5hI9NdXGodnqRWOIbjvWZfLVo9eULi01CyPjVTyPqm1bN2shsd0ZQ0lI4wWR+ER921DmErF6gtfOuAw1EqzIDq6gzwPRFWiCywMtccirvwCoa26Or77KbTRdnlEDU4Pu9JnMSQp3wZNZKHWjQ2Lrl8aiPsRMWYj7ExulWqIlN0Jpyt0GYaUQarOFW5bfSnfqyVPGY03pAghBNzTivKuRD0x1f7W7VUHsKZ9cnDNUFLiRefnQrHGOT8YfmwOqC8rdB/bi5spAgMBAAECggEAGO2oii7GQb0JKT6J7BE6giUDI0gWateicnjCAED5hjOz6wqysM/wY0Z2h1b1PJLN6H6KAOwp73wyB2SVwnm3OfPCpKa4PNkKqtuNwlHC+vTJc09qvkCnOmPIrZ1fuZXTQS/Z4k4ScJZp/AgA2iZFPwz5dmWGtlypQTEkxgKtVl/Q2FKmgB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BAQEFAAOCAQ8AMIIBCgKCAQEAmdoDJRQk+BZSNQKxTN+XB/sIHU7vYbsQf5e2QsmzfKAItI/p7GE7kQNE4aBcKIiM03hisuY3tO/eyOFFRlIopu9y5ePubYbVuLApYCsf4rkb+batWcieumbPhAQtarzeYaN8HWjuOD9SmNjwzU4H7suaUpPYSMuWQAC3FJi3OqxcddtosxkQO5KSH1VZ/19mWu1H+gwGodKGVG3t/aahsPOIZkFr+Wr3Br7r0kswDGJOMmVVgFlGeFSHOonApe33/bmHzY6jtieJw/9z/nWZm5j53HpoK+9OgMKSd04Q1Q+ln6Cn5yddlUfpAYdKxrk54+X1ywq4hges3TnJrylwgQIDAQAB" ;

        @RequestMapping("/alipay")
    @ResponseBody
    public void pay(HttpServletRequest request, HttpServletResponse response,String total_amount,String subject) throws Exception {
            String body = "121311212";
            String out_trade_no =uuid();
if(subject==null){
    subject = "1111"+uuid();
     body = "bzj";
    out_trade_no ="11111111"+uuid();

}

        // 商户订单号，商户网站订单系统中唯一订单号，必填


            // 订单名称，必填
     //   String subject = uuid();
        // 付款金额，必填

        // 商品描述，可空
        // 超时时间 可空
        // 销售产品码 必填
        String product_code = "QUICK_WAP_PAY";
        /**********************/
        // SDK 公共请求类，包含公共请求参数，以及封装了签名与验签，开发者无需关注签名与验签
        //调用RSA签名方式
        AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);
        AlipayTradeWapPayRequest alipay_request = new AlipayTradeWapPayRequest();

        // 封装请求支付信息
        AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
        model.setOutTradeNo(out_trade_no);
        model.setSubject(subject);
        model.setTotalAmount(total_amount);
        model.setBody(body);

        model.setProductCode(product_code);
        alipay_request.setBizModel(model);
        // 设置异步通知地址
        alipay_request.setNotifyUrl(AlipayConfig.notify_url);
        // 设置同步地址
        alipay_request.setReturnUrl(AlipayConfig.return_url);



        // form表单生产
        String form = "";
        try {
            // 调用SDK生成表单

            form = client.pageExecute(alipay_request).getBody();
            response.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
            response.getWriter().write(form);//直接将完整的表单html输出到页面
            response.getWriter().flush();
            response.getWriter().close();
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }








    }

    @RequestMapping("/alipay1")
    @ResponseBody
    public void pay1(HttpServletRequest request, HttpServletResponse response,String out_trade_no,String total_amount) throws Exception {
        String body = "121311212";
        // 商户订单号，商户网站订单系统中唯一订单号，必填
        // 订单名称，必填
         String subject = uuid();
        // 付款金额，必填

        // 商品描述，可空
        // 超时时间 可空
        // 销售产品码 必填
        String product_code = "QUICK_WAP_PAY";
        /**********************/
        // SDK 公共请求类，包含公共请求参数，以及封装了签名与验签，开发者无需关注签名与验签
        //调用RSA签名方式
        AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);
        AlipayTradeWapPayRequest alipay_request = new AlipayTradeWapPayRequest();

        // 封装请求支付信息
        AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
        model.setOutTradeNo(out_trade_no);
        model.setSubject(subject);
        model.setTotalAmount(total_amount);
        model.setBody(body);

        model.setProductCode(product_code);
        alipay_request.setBizModel(model);
        // 设置异步通知地址
        alipay_request.setNotifyUrl(AlipayConfig.notify_url);
        // 设置同步地址
        alipay_request.setReturnUrl(AlipayConfig.return_url);



        // form表单生产
        String form = "";
        try {
            // 调用SDK生成表单

            form = client.pageExecute(alipay_request).getBody();
            response.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
            response.getWriter().write(form);//直接将完整的表单html输出到页面
            response.getWriter().flush();
            response.getWriter().close();
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }








    }





    @RequestMapping("/returnurl")
    @ResponseBody
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws Exception {
        //获取支付宝GET过来反馈信息
        Map<String, String> params = new HashMap<String, String>();
        Map requestParams = request.getParameterMap();
        for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
            String name = (String) iter.next();
            String[] values = (String[]) requestParams.get(name);
            String valueStr = "";
            for (int i = 0; i < values.length; i++) {
                valueStr = (i == values.length - 1) ? valueStr + values[i]
                        : valueStr + values[i] + ",";
            }
            //乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
            valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
            params.put(name, valueStr);
        }

        //获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//，
        //商户订单号
        String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
        //支付宝交易号
        String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");
        //获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)//
        //计算得出通知验证结果
        //boolean AlipaySignature.rsaCheckV1(Map<String, String> params, String publicKey, String charset, String sign_type)
        boolean verify_result = AlipaySignature.rsaCheckV1(params, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, "RSA2");

        if (verify_result) {//验证成功
            //
            //请在这里加上商户的业务逻辑程序代码
            //验证成功跳转到前台支付结果页面
            response.sendRedirect("http://ip:port/paysuccess.html?out_trade_no=" + out_trade_no);
            //——请根据您的业务逻辑来编写程序（以上代码仅作参考）——

            //
        } else {
            //该页面可做页面美工编辑
            response.sendRedirect("http://ip:port/payfail.html");
        }

    }

//
//    @RequestMapping("/alipay")
//    @ResponseBody
//    public void doPost(HttpServletRequest httpRequest,
//                       HttpServletResponse httpResponse) throws ServletException, IOException {
//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2"); //获得初始化的AlipayClient
//        AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();//创建API对应的request
//        alipayRequest.setReturnUrl("http://domain.com/CallBack/return_url.jsp");
//        alipayRequest.setNotifyUrl("http://domain.com/CallBack/notify_url.jsp");//在公共参数中设置回跳和通知地址
//        alipayRequest.setBizContent("{" +
//                " \"out_trade_no\":\"20150320010101002\"," +
//                " \"total_amount\":\"88.88\"," +
//                " \"subject\":\"Iphone6 16G\"," +
//                " \"product_code\":\"QUICK_WAP_PAY\"" +
//                " }");//填充业务参数
//        String form="";
//        try {
//            form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单
//        } catch (AlipayApiException e) {
//            e.printStackTrace();
//        }
//        httpResponse.setContentType("text/html;charset=" + CHARSET);
//        httpResponse.getWriter().write(form);//直接将完整的表单html输出到页面
//        httpResponse.getWriter().flush();
//        httpResponse.getWriter().close();
//    }
//
//




    public void payController(HttpServletRequest request1, HttpServletResponse response1) throws IOException, AlipayApiException {
//
//
//
//        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
//                "app_id",
//                "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCHDW1B5+04AGZjlVMTIkYeVihXbRXLsB5ZVI2jqyJ0tvi2+2bxr7xZR8yn+ancETx885aZue3ALWdpS5hI9NdXGodnqRWOIbjvWZfLVo9eULi01CyPjVTyPqm1bN2shsd0ZQ0lI4wWR+ER921DmErF6gtfOuAw1EqzIDq6gzwPRFWiCywMtccirvwCoa26Or77KbTRdnlEDU4Pu9JnMSQp3wZNZKHWjQ2Lrl8aiPsRMWYj7ExulWqIlN0Jpyt0GYaUQarOFW5bfSnfqyVPGY03pAghBNzTivKuRD0x1f7W7VUHsKZ9cnDNUFLiRefnQrHGOT8YfmwOqC8rdB/bi5spAgMBAAECggEA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tm7xjdalsXlAnwjkxs1nL+biL10B9hBdNmPLNv5L7N3ZnK3buJbO+319b5bXQprSDarrF1VcTa7EelKtt4xr3eu6OGmBTejmQqC8UQ3SA6wYQtOB5yl+qljmMYjvaeUM5Nlu",
//                "json","GBK",
//                "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmdoDJRQk+BZSNQKxTN+XB/sIHU7vYbsQf5e2QsmzfKAItI/p7GE7kQNE4aBcKIiM03hisuY3tO/eyOFFRlIopu9y5ePubYbVuLApYCsf4rkb+batWcieumbPhAQtarzeYaN8HWjuOD9SmNjwzU4H7suaUpPYSMuWQAC3FJi3OqxcddtosxkQO5KSH1VZ/19mWu1H+gwGodKGVG3t/aahsPOIZkFr+Wr3Br7r0kswDGJOMmVVgFlGeFSHOonApe33/bmHzY6jtieJw/9z/nWZm5j53HpoK+9OgMKSd04Q1Q+ln6Cn5yddlUfpAYdKxrk54+X1ywq4hges3TnJrylwgQIDAQAB","RSA2");
//        AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
//        request.setBizContent("{" +
//                "\"body\":\"Iphone6 16G\"," +
//                "\"subject\":\"大乐透\"," +
//                "\"out_trade_no\":\"70501111111S001111119\"," +
//                "\"timeout_express\":\"90m\"," +
//                "\"time_expire\":\"2016-12-31 10:05\"," +
//                "\"total_amount\":9.00," +
//                "\"seller_id\":\"2088102147948060\"," +
//                "\"auth_token\":\"appopenBb64d181d0146481ab6a762c00714cC27\"," +
//                "\"goods_type\":\"0\"," +
//                "\"quit_url\":\"http://www.taobao.com/product/113714.html\"," +
//                "\"passback_params\":\"merchantBizType%3d3C%26merchantBizNo%3d2016010101111\"," +
//                "\"product_code\":\"QUICK_WAP_PAY\"," +
//                "\"promo_params\":\"{\\\"storeIdType\\\":\\\"1\\\"}\"," +
//                "\"extend_params\":{" +
//                "\"sys_service_provider_id\":\"2088511833207846\"," +
//                "\"hb_fq_num\":\"3\"," +
//                "\"hb_fq_seller_percent\":\"100\"," +
//                "\"industry_reflux_info\":\"{\\\\\\\"scene_code\\\\\\\":\\\\\\\"metro_tradeorder\\\\\\\",\\\\\\\"channel\\\\\\\":\\\\\\\"xxxx\\\\\\\",\\\\\\\"scene_data\\\\\\\":{\\\\\\\"asset_name\\\\\\\":\\\\\\\"ALIPAY\\\\\\\"}}\"," +
//                "\"card_type\":\"S0JP0000\"" +
//                "    }," +
//                "\"sub_merchant\":{" +
//                "\"merchant_id\":\"2088000603999128\"," +
//                "\"merchant_type\":\"alipay: 支付宝分配的间连商户编号, merchant: 商户端的间连商户编号\"" +
//                "    }," +
//                "\"merchant_order_no\":\"20161008001\"," +
//                "\"enable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
//                "\"disable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
//                "\"store_id\":\"NJ_001\"," +
//                "      \"goods_detail\":[{" +
//                "        \"goods_id\":\"apple-01\"," +
//                "\"alipay_goods_id\":\"20010001\"," +
//                "\"goods_name\":\"ipad\"," +
//                "\"quantity\":1," +
//                "\"price\":2000," +
//                "\"goods_category\":\"34543238\"," +
//                "\"categories_tree\":\"124868003|126232002|126252004\"," +
//                "\"body\":\"特价手机\"," +
//                "\"show_url\":\"http://www.alipay.com/xxx.jpg\"" +
//                "        }]," +
//                "\"settle_info\":{" +
//                "        \"settle_detail_infos\":[{" +
//                "          \"trans_in_type\":\"cardAliasNo\"," +
//                "\"trans_in\":\"A0001\"," +
//                "\"summary_dimension\":\"A0001\"," +
//                "\"settle_entity_id\":\"2088xxxxx;ST_0001\"," +
//                "\"settle_entity_type\":\"SecondMerchant、Store\"," +
//                "\"amount\":0.1" +
//                "          }]," +
//                "\"settle_period_time\":\"7d\"" +
//                "    }," +
//                "\"invoice_info\":{" +
//                "\"key_info\":{" +
//                "\"is_support_invoice\":true," +
//                "\"invoice_merchant_name\":\"ABC|003\"," +
//                "\"tax_num\":\"1464888883494\"" +
//                "      }," +
//                "\"details\":\"[{\\\"code\\\":\\\"100294400\\\",\\\"name\\\":\\\"服饰\\\",\\\"num\\\":\\\"2\\\",\\\"sumPrice\\\":\\\"200.00\\\",\\\"taxRate\\\":\\\"6%\\\"}]\"" +
//                "    }," +
//                "\"specified_channel\":\"pcredit\"," +
//                "\"business_params\":\"{\\\"data\\\":\\\"123\\\"}\"," +
//                "\"ext_user_info\":{" +
//                "\"name\":\"李明\"," +
//                "\"mobile\":\"16587658765\"," +
//                "\"cert_type\":\"IDENTITY_CARD\"," +
//                "\"cert_no\":\"362334768769238881\"," +
//                "\"min_age\":\"18\"," +
//                "\"fix_buyer\":\"F\"," +
//                "\"need_check_info\":\"F\"" +
//                "    }" +
//                "  }");
//        AlipayTradeWapPayResponse response = alipayClient.pageExecute(request);
//        if(response.isSuccess()){
//            System.out.println("调用成功");
//
//
//        // 请求
//        String form = "";
//        try {
//            form = alipayClient.pageExecute(request).getBody(); // 调用SDK生成表单
//            System.out.println("form==>" + form);
//        } catch (AlipayApiException e) {
//            e.printStackTrace();
//        }
//            response1.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
//            response1.getWriter().write(form);// 直接将完整的表单html输出到页面
//            response1.getWriter().flush();
//            response1.getWriter().close();
//
//            System.err.println(response.isSuccess());
//        } else {
//            System.out.println("调用失败");
//        }
//











//        // 获得初始化的AlipayClient
//        AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.APP_ID, AlipayConfig.APP_PRIVATE_KEY, "json", AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.sign_type);
//
//        // 设置请求参数
//        AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
//        alipayRequest.setReturnUrl(AlipayConfig.return_url);
//        alipayRequest.setNotifyUrl(AlipayConfig.notify_url);
//
//        // 商户订单号，商户网站订单系统中唯一订单号，必填
//        String out_trade_no = request.getParameter("out_trade_no");
//        // 付款金额，必填
//        String total_amount = request.getParameter("total_amount");
//        // 订单名称，必填
//        String subject = request.getParameter("subject");
//        // 商品描述，可空
//        String body = request.getParameter("body");
//
//        alipayRequest.setBizContent("{\"out_trade_no\":\"" + out_trade_no + "\","
//                + "\"total_amount\":\"" + total_amount + "\","
//                + "\"method\":\"" + "talipay.trade.pay" + "\","
//                + "\"subject\":\"" + subject + "\","
//                + "\"body\":\"" + body + "\","
//                + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
//
//
//        // 请求
//        String form = "";
//        try {
//            form = alipayClient.pageExecute(alipayRequest).getBody(); // 调用SDK生成表单
//            System.out.println("form==>" + form);
//        } catch (AlipayApiException e) {
//            e.printStackTrace();
//        }
//        response.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
//        response.getWriter().write(form);// 直接将完整的表单html输出到页面
//        response.getWriter().flush();
//        response.getWriter().close();
    }

//
//    @RequestMapping("/getContext1")
//    public String alipayPayChongRequest() throws AlipayApiException {
//        AlipayClient alipayClient = AlipayConfig.getAlipayClient();
//        //创建API对应的request类(主要是这里变化了)
//        AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
//        request.setReturnUrl(AlipayConfig.OWreturn_url);// 回跳地址
//        request.setNotifyUrl(AlipayConfig.OWnotify_url);// 通知地址
//        AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
//        long timeStart = Calendar.getInstance().getTimeInMillis();
//        model.setOutTradeNo(timeStart + "");
//        model.setSubject("测试商品");
//        model.setTotalAmount("0.01");
//        model.setBody("测试商品");
//        model.setTimeoutExpress("30m");
//        model.setProductCode("QUICK_WAP_PAY");
//        request.setBizModel(model);
//        String form = alipayClient.pageExecute(request).getBody (); //调用SDK生成表单
//        System.out.println(form);
//        return form;
//
//    }

}